Skip to main content

Portfolio Lens

Overview

The Portfolio Lens contract is a collection of view-only helper functions to fetch position, asset and debt data. It also provides a helper function to predict the address for new positions deployed using CREATE2.

State Variables

POOL

Address to the protocol's pool instance

Pool public immutable POOL;

RISK_ENGINE

Address to the protocol's risk engine instance

RiskEngine public immutable RISK_ENGINE;

POSITION_MANAGER

Address to the protocol's position manager instance

PositionManager public immutable POSITION_MANAGER;

Functions

constructor

constructor(address pool, address riskEngine, address positionManager);

Parameters

NameTypeDescription
pooladdressAddress to the protocol's pool instance
riskEngineaddressAddress to the protocol's risk engine instance
positionManageraddressAddress to the protocol's position manager instance

getPortfolioData

Fetch current state for multiple positions at once

function getPortfolioData(address[] calldata positions) public view returns (PortfolioData memory portfolioData);

Parameters

NameTypeDescription
positionsaddress[]Array of position addresses

Returns

NameTypeDescription
portfolioDataPortfolioDataArray of current position data for each given position

getPositionData

Fetch current state for a given position

function getPositionData(address position) public view returns (PositionData memory positionData);

Parameters

NameTypeDescription
positionaddressAddress of the position

Returns

NameTypeDescription
positionDataPositionDataCurrent position data for the given position

getAssetData

Fetch data for all assets currently held by a position

Could return values with zero amount if AddToken / RemoveToken has not been called

function getAssetData(address position) public view returns (AssetData[] memory assetData);

Parameters

NameTypeDescription
positionaddressAddress of the position

Returns

NameTypeDescription
assetDataAssetData[]List of data for assets currently held by the given position

getDebtData

Fetch data for all active debt associated a given position

function getDebtData(address position) public view returns (DebtData[] memory debtData);

Parameters

NameTypeDescription
positionaddressAddress of the position

Returns

NameTypeDescription
debtDataDebtData[]List of pool-wise debt data currently owed by the given position

predictAddress

Utility function to predict the CREATE2 address for a new position

function predictAddress(address owner, bytes32 salt) external view returns (address newPosition, bool available);

Parameters

NameTypeDescription
owneraddressAddress of the new position owner
saltbytes32CREATE2 salt for the new position

Returns

NameTypeDescription
newPositionaddressPredicted address for the new position
availableboolBoolean which is false if the predicted position address already has code deployed to it

Structs

PortfolioData

Container for data associated with multiple positions

struct PortfolioData {
PositionData[] positions;
}

PositionData

Container for data associated with a single position

struct PositionData {
address position;
address owner;
AssetData[] assets;
DebtData[] debts;
}

AssetData

Generic container for position asset data

struct AssetData {
address asset;
uint256 amount;
uint256 valueInEth;
}

DebtData

Generic container for position debt data

struct DebtData {
uint256 poolId;
address asset;
uint256 amount;
uint256 valueInEth;
uint256 interestRate;
}